Declaration of external variables in ST

Syntax
VAR_EXTERNAL (* optional_begin *) CONSTANT (* optional_end *)
  name_1, name_2, ..., name_n : data-type;
  name_3, name_4, ..., name_n : STRING[length];
  name_5, name_6, ..., name_n : ARRAY [x..y] OF type;
  name_7, name_8, ..., name_n : ARRAY [x1..y1, x2..y2, x3..y3] OF data-type;
 
(* Additional pieces of data are also possible for the variables. *)
(* Note: If a function block type is used as type for the variable, it is actually a function block instance. *)

(* Note: If a class type is used as type for the variable, it is actually a class instance. *)

END_VAR
Meaning

declaration of one or more →external variables, name_1, name_2 etc. must be →IEC-identifiers.
The declaration of more sections of this kind is allowed. The declaration of external variables is possible within the declaration of a →function block, of a →class, of a →function or of a →method.. Such external variables are used to access →global variables with the same name and of the same type. These global variables are declared within a →program (within an ST-object) or within a →resource (within a PLC-object).
The declaration of external variables is possible within declaration of a program. Such external variables are used to access global variables which were declared within a resource (within a PLC-object). 

Providing the optional keyword CONSTANT prevents all external variables of this section from being overwritten during program execution (makes them →constants). The keyword CONSTANT is mandatory if the corresponding global variable has been declared CONSTANT.
See "Supported data types" to learn which data types are supported for the declaration. It is also possible to declare:

Good to know

(grey lightbulb) Moreover, Neuron Power Engineer allows you to specify additional data for the declaration. See "Defining description, comment, JSON string or type for variables or data types" for details.

(grey lightbulb) If you prefer that Neuron Power Engineer is creating the syntax for you: The application navigator provides the possibility to declare external variables and to have the declarations based on the already existing global variables. This is done when you drag the global variables from a global-object onto a →POU. Details: See "Declaring external variables by dragging and dropping global variables into POUs". In this case, you do not need to know the syntax described above.

(grey lightbulb) Within a section VAR_EXTERNAL...END_VAR, it is also possible to declare function block instances or class instances.

Example 1

VAR_EXTERNAL
  portSetting : INT;
  upTime : TIME;
  gVar1: ARRAY [1..2] of BOOL;
  gVar2: STRING[10];
END_VAR
Example 2
VAR_EXTERNAL
  VALVE_POS : INT;
END_VAR